<script>
	function showPhotoProfile(input) {
	    if (input.files && input.files[0]) {
	        var reader = new FileReader();	        
	        reader.onload = function (e) {
	            $('#imgPhotoProfile').attr('src', e.target.result);
	            $("#webcamPhoto").val("");
	        }	        
	        reader.readAsDataURL(input.files[0]);	        
	    }
	}
	
	function cancel(){
		window.close();
	}
	
	
	function showClassHistory(){
		$("#tblClassHist").jqGrid("setGridParam",{
			postData:{
				"student_id":$("#id").val(),				
			},
			datatype:"json"
		}).trigger("reloadGrid");
	
	}
	
	
	function getFamily(){
		
		$("#tblFamily").jqGrid("setGridParam",{
			postData:{
				"student_id":$("#id").val(),				
			},
			datatype:"json"
		}).trigger("reloadGrid");
	}
	
	
	
	$(function(){
		$("#photoProfile").change(function(){
			showPhotoProfile(this);
		});

		$("#tblClassHist").jqGrid({
			url:'index.php?r=akademik/siswa/penempatan_kelas/listClassHist',
			datatype: 'local',
			loadonce:true,
			mtype:"GET",
			autowidth:true,
			height:"100%",
			width:"100%",
			altRows:true,
			ignoreCase:true,
			//$strFields="id,department_id,sid,name,if(gender='P','Pria','Wanita') as gender,birth_date,address,home_phone,handphone,email,ayah_nama,ibu_nama,wali_nama,is_active";
			colNames: ['id','student ID','Tahun Ajaran','Tingkatan','Kelas'],
			colModel: [
				{name: 'id', index: 'id', width: 20,hidden:true,sorttype:'int',formatter:'int'},
				{name: 'student_id', index: 'student_id', width: 20,hidden:true,sorttype:'int',formatter:'int'},
				{name: 'tahun_ajaran_name', index: 'tahun_ajaran_name', width: 100,search:true},
				{name: 'tingkatan_name', index: 'tingkatan_name', width: 200,search:true},
				{name: 'kelas_name', index: 'kelas_name', width: 200,search:true},
			],
			gridview: true,
			rownumbers: false,
			rowNum: 10,
			rowList: [5, 10, 15],
			pager: '#navTblData',
			viewrecords: true,
			caption: '<?php echo Yii::t("label", "Riwayat Kelas"); ?>',
			jsonReader : { 
				root:"model",
				repeatitems: false			
			},
			loadComplete:function(data){
				console.log(data);
			},
		});
		$("#tblClassHist").jqGrid('navGrid','#navTblClasHist',{add:false,edit:false,search:false,del:false,refresh:false});				
	});	
</script>
<div style="width:1080px">
	<form id="frmSubmit" action="index.php?r=akademik/siswa/main/editActive" method="POST" enctype='multipart/form-data' >		
		<?php
			$labelWidth ="100px";			
		?>
		
		<div style="width:100%">
			<div>
				<input type="hidden" id="id" name="id" value="<?php echo $id; ?>" size =10/>
				<input type="hidden" id="op" name="op" value="<?php echo $op; ?>" size =10/></br>
			</div>
			<div>
				<label class="form  " style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Department");?></label>
				<label class="form  " style="width:10px">:</label>
				<label class="form" style="width:200px"><?php echo $department_id ;?></label>
				<input type="hidden" id="department_id" name="department_id" value="<?php echo $department_id;?>" size="20" readonly class="disabled" />
				
				<label class="form  " style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Tingkat");?></label>
				<label class="form  " style="width:10px">:</label>
				<label class="form" style="width:<?php echo $labelWidth;?>"><?php echo $tingkatan_name ;?></label>
			</div>
			<div>
				<label class="form  " style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Tahun Ajaran");?></label>
				<label class="form  " style="width:10px">:</label>
				<label class="form" style="width:200px"><?php echo $tahun_ajaran["name"] ;?></label>
				<input type="hidden" id="tahun_ajaran_id" name="tahun_ajaran_id" value="<?php echo $tahun_ajaran["id"];?>" size="20" readonly class="disabled"/>
				
				<label class="form  " style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Kelas");?></label>
				<label class="form  " style="width:10px">:</label>
				<label class="form" style="width:<?php echo $labelWidth;?>"><?php echo $kelas_name ;?></label>
								
			</div>
			<div><input id="is_active" name="is_active" type="checkbox" <?php echo $is_active?"checked":""; ?> /> <label>Active</label></div>
		</div>
		<hr>
		
		<div id="accordion">
			<style>
				#accordion h1{
					width:95%;
					background-color:#828282;
					color:#ffffff;
					padding:5px
				}
				#accordion table{
					width:95%;
					border:1px solid #000
				}
				
			</style>
			
			<div>
				<img id="imgPhotoProfile" src="<?php echo $imgPhotoProfile;?>" alt="" style="width:120px;height:140px;border:1px solid #2B3856;cursor:pointer" onclick ="javascript:document.getElementById('photoProfile').click();" />
				
				<div>
					<label class="form" style="display:none;width:<?php echo $labelWidth;?>">Photo Profile</label> 
					<input type='file' id="photoProfile" name="photoProfile" accept="image/*" style='visibility:hidden;display:none' />
				</div>
				<div>
					<textarea style="display:none" id="webcamPhoto" name="webcamPhoto"></textarea>
				</div>					
			</div>
			
			<h1>Informasi Siswa</h1>
			<div>
				<div style="padding-top:10px;padding-bottom:10px">
					<div>
						<label class="form" style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Student ID");?></label>
						<label class="form  " style="width:10px">:</label>						
						<label><?php echo $sid;?></label>					
					</div>
					
					<div>
						<label class="form  " style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Status");?></label>
						<label class="form  " style="width:10px">:</label>
						<label><?php echo $status_siswa;?></label>
					</div>										
					
					<div>
						<label class="form  " style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Nama");?></label>
						<label class="form  " style="width:10px">:</label>
						<label><?php echo $name;?></label>
					</div>	
					<div>
						<label class="form  " style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Pangilan");?></label>
						<label class="form  " style="width:10px">:</label>
						<label><?php echo $nick_name;?></label>						
					</div>
					<div>
						<label class="form  " style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Jenis Kelamin");?></label>
						<label class="form  " style="width:10px">:</label>
						<label><?php echo $gender=="L"?"Laki-Laki":"Perempuan";?></label>
					</div>
					<div>
						<label class="form  " style="width:<?php echo $labelWidth;?>;vertical-align:top"><?php echo Yii::t("label","Tempat Lahir");?></label>
						<label class="form  " style="width:10px">:</label>
						<label><?php echo $birth_place; ?></label>						
					</div>
					<div>
						<label class="form  " style="width:<?php echo $labelWidth;?>;vertical-align:top"><?php echo Yii::t("label","Tanggal Lahir");?></label>
						<label class="form  " style="width:10px">:</label>
						<label><?php echo $birth_date; ?></label>
					</div>
					<div>
						<label class="form" style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Agama");?></label>
						<label class="form  " style="width:10px">:</label>
						<label><?php echo $religion; ?></label>
					</div>
					<div>
						<label class="form" style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Suku");?></label>
						<label class="form  " style="width:10px">:</label>
						<label><?php echo $ethnic; ?></label>
					</div>
					
					<div>
						<label class="form" style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Kewarganegaraan");?></label>
						<label class="form  " style="width:10px">:</label>
						<label><?php echo $citizenship; ?></label>
					</div>
				</div>
			</div>
			
			<h1>Informasi Contact</h1>
			<div style="padding-top:10px;padding-bottom:10px">
				<div>
					<label class="form" style="width:<?php echo $labelWidth;?>;vertical-align:top"><?php echo Yii::t("label","Alamat");?></label>
					<label class="form  " style="width:10px">:</label>
					<label><?php echo $address; ?></label>
				</div>
			
				<div>
					<label class="form" style="width:<?php echo $labelWidth;?>;vertical-align:top"><?php echo Yii::t("label","Provinsi");?></label>
					<label class="form  " style="width:10px">:</label>
					<label><?php echo $propinsi; ?></label>
				</div>
				<div>
					<label class="form" style="width:<?php echo $labelWidth;?>;vertical-align:top"><?php echo Yii::t("label","Kota");?></label>
					<label class="form  " style="width:10px">:</label>
					<label><?php echo $kota; ?></label>
				</div>
				<div>
					<label class="form" style="width:<?php echo $labelWidth;?>;vertical-align:top"><?php echo Yii::t("label","Area");?></label>
					<label class="form  " style="width:10px">:</label>
					<label><?php echo $area; ?></label>
				</div>
				<div>
					<label class="form" style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Kode Pos");?></label>
					<label class="form  " style="width:10px">:</label>
					<label><?php echo $post_code; ?></label>
				</div>
				<div>
					<label class="form" style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","No. Telp");?></label>
					<label class="form  " style="width:10px">:</label>
					<label><?php echo $home_phone; ?></label>					
				</div>
				<div>
					<label class="form" style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Handphone");?></label>
					<label class="form  " style="width:10px">:</label>
					<label><?php echo $handphone; ?></label>
				</div>
				<div>
					<label class="form" style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Email");?></label>
					<label class="form  " style="width:10px">:</label>
					<label><?php echo $email; ?></label>
				</div>
			</div>			
			
			
			<h1>Data Kesehatan</h1>
			<div>
				<div>
					<label class="form" style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Golongan darah");?></label>
					<label class="form  " style="width:10px">:</label>
					<label><?php echo $gol_darah; ?></label>
				</div>
				<div>
					<label class="form" style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Berat");?></label>
					<label class="form  " style="width:10px">:</label>
					<label><?php echo $berat_kg; ?> Kg</label>
				</div>
				<div>
					<label class="form" style="width:<?php echo $labelWidth;?>"><?php echo Yii::t("label","Tinggi");?></label>
					<label class="form  " style="width:10px">:</label>
					<label><?php echo $tinggi_cm; ?> Cm</label>
				</div>
				<div style="margin-top:20px;margin-bottom:10px">
					<label class="form" style="width:<?php echo $labelWidth;?>;vertical-align:top"><?php echo Yii::t("label","Riwayat Penyakit");?></label>
					<label class="form  " style="width:10px">:</label>
				</div>
				<div>
					<label><?php echo $riwayat_penyakit; ?></label>
				</div>
			</div>
			
			<h1>Keluarga / Wali </h1>
			<div>
				<table>
					<thead>
						<tr>
							<th>Type</th>						
							<th>Nama</th>
							<th>Tlp Rumah</th>
							<th>Tlp Kantor</th>
							<th>Hp</th>
							<th>Email</th>
						</tr>
					</thead>
					<tbody>
						<?php
							foreach ($arrFamily as $family){
								echo "<tr>";
									echo "<td>$family[family_type]</td>";
									echo "<td>$family[name] ". $family["is_alm"] == 1 ? "(Almarhum)" :"" . "</td>";
									echo "<td>$family[home_phone]</td>";
									echo "<td>$family[office_phone]</td>";
									echo "<td>$family[mobile_phone]</td>";
									echo "<td>$family[email_address]</td>";
								echo "</tr>";
 							}
						?>
					</tbody>
				</table>
			</div>
		</div>		
	</form>
	
</div>